<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="zhaozhenguo">
		<title>礼品信息查询</title>
		<!--js库及样式-->
		<script LANGUAGE="javascript" src="../script/common.js" type="text/javascript"></script>
		<!--动态js-->
		<script type="text/javascript">
			//全局变量
			var org = Common.cOrg();	//当前单位
			var qt ={};	
			var b=false;			//数据表格对象
			var mmm;
			//页面加载方法
			function load(){
	        	    Eui.showNavigation();
			  	var mainform = $("mainform");
			  	Common.initSql(mainform.giftType,"gift_info_add_giftType",{},"0","1","全部");
				Common.initSql(mainform.subType,"gift_info_add_subType",{},"0","1","全部");
				createTable();
				setOrg(Common.cOrg());	
			}
			//-------导航页面-------商品大类及联商品小类--------
			function changes(s){
				if(s){
					Common.initSql($("mainform").subType,"gift_info_add_subTypeId",{subTypeId:s},"0","1","全部");
					subType = s;
				}else{
					Common.initSql($("mainform").subType,"gift_info_add_subType",{},"0","1","全部");
				} 	
			}
			//商品小类及联商品大类
			function subchanges(s){
				if(s){
					DWR.call("giftStorageService.getParentTypeId",s,function(v){
						$("giftType").value=v.id;	
					});
				}else if(!s && subType){
					subType = null;
				}else{
					Common.initSql($("mainform").giftType,"gift_info_add_giftType",{},"0","1","全部");
				} 	
			}
			//选择单位控件
	function setOrg(sorg) {
		$("mainform").orgLevel.value = sorg.orgLevel;
		$("mainform").orgId.value = sorg.id;
	    $("mainform").unifiedBuyLevel.value = sorg.name;
	}
	
			function createTable(b){
				var columns = [];
				
				/*var columns = [
					{title:"礼品编号",width:"16%"},
					{title:"礼品名称",width:"16%"},
					{title:"商品类型",width:"16%"},
					{title:"单价",width:"16%",render:function(v){return Format.formatMoney(v)}},
					{title:"计量单位",width:"10%"},
					{title:"统采级别",width:"10%"},
					{title:"礼品统采机构",width:"16%"}
				]*/
				if(b){
					qt = new QueryTable("gift_info_add_query_true","mainform","datalist",columns);
				}else{
					qt = new QueryTable("gift_info_add_query_false","mainform","datalist",columns);
				}
			}
			function showData(){
				DWR.call("giftStorageService.getJb",$("subType").value,function(v){
		       		//createTable(v);
					b=v;
					qt.showTable();			//qt为全局的QueryTable对象
				});		
			}	
		</script>
	</head>
	
	
	<body onload=" load()">
		<!--页面导航--> 
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="listview">		
			<div class="searchForm">
				<form id="mainform" name="mainform">
					<input type="hidden" name="orgId"/>
			            <input type="hidden" name="orgLevel"/>
					 <input type="hidden" name="subTypeId">
						
					<table cellSpacing=0 cellPadding=3 width="100%" border=0>
					    <tr>
					        <td><label>礼品编号</label> <input type="text" name="giftCode" maxlength=15></td>
					        <td><label>礼品名称</label> <input type="text" name="giftName" maxlength=40></td>  
						</tr>
						<tr>
							
							<td><label>商品大类</label> <select name="giftType" onchange="changes(this.value)"></select></td>
							<td><label>商品子类</label> <select name="subType" onchange="subchanges(this.value)"></select></td>
							
						</tr>
						<tr>
						<td><label>统采机构 </label><input type="text" name="unifiedBuyLevel" readonly class="readonly">
						 <a class="orga" title="选择所属机构" href="javascript:void(0)" onclick="SystemMgnt.selOrg(setOrg)">&nbsp;&nbsp;</a> 
					    <td><button type="button" onclick="showData()">查 询</button></td>	 
					</tr>
					</table>
				</form>
			</div>			
			<div id="datalist"></div>
		</div>	
	</body>
</HTML>